define(["jquery"],function(){
	return function(own){
		own.banSelectText();
		$("#home").mouseover(function(){
			$(this).children("a").text("首页").css({color:"red"});
		}).mouseout(function(){
			$(this).children("a").text("HOME").css({color:"#000"});
		})
		$("#sales").mouseover(function(){
			$(this).children("a").text("闪购促销").css({color:"red"});
		}).mouseout(function(){
			$(this).children("a").text("SALES").css({color:"#000"});
		})
		$("#activity").mouseover(function(){
			$(this).children("a").text("最新活动").css({color:"red"});
		}).mouseout(function(){
			$(this).children("a").text("ACTIVITY").css({color:"#000"});
		})
		$("#sale").mouseover(function(){
			$(this).children("a").text("智能售卖").css({color:"red"});
		}).mouseout(function(){
			$(this).children("a").text("SALE").css({color:"#000"});
		})
		$("#taste").mouseover(function(){
			$(this).children("a").text("免费试吃").css({color:"red"});
		}).mouseout(function(){
			$(this).children("a").text("TASTE").css({color:"#000"});
		})
		$("#platform").mouseover(function(){
			$(this).children("a").text("企业平台").css({color:"red"});
		}).mouseout(function(){
			$(this).children("a").text("PLATFORM").css({color:"#000"});
		})
		$("#about").mouseover(function(){
			$(this).children("a").text("关于我们").css({color:"red"});
		}).mouseout(function(){
			$(this).children("a").text("ABOUT").css({color:"#000"});
		})
		$("#nav_all>ol>li>span").each(function(index){
			$(this).css({"background-position-Y":-index * 29});
		})
		$("#nav_all ul").each(function(index){
			$(this).css({"top":-index*66});
		})
		$("#nav_all").on("mouseover",function(){
			$(this).children("ol").css({"display":"block"});
			$(this).children("ol").children("li").on("mouseover",function(){
				$(this).css({"background":"rgb(255,255,255)"});
				$(this).children("a").css({"color":"#e51e13"});
				$(this).children("span").css({"background-position-X":"-29px"});
				$(this).children("em").css({"color":"#e51e13"});
				$(this).children("ul").css({"z-index":"-2"}).stop().show().animate({"left":"210px"},150).children("li").hover(function(){
					$(this).children("a").css({"color":"#e51e13","text-decoration":"underline"})
				},function(){
					$(this).children("a").css({"color":"#666","text-decoration":"none"})
				})
			}).on("mouseout",function(){
				$(this).css({"background":"#e51e13"});
				$(this).children("a").css({"color":"rgb(255,255,255)"});
				$(this).children("span").css({"background-position-X":"0"});
				$(this).children("em").css({"color":"rgb(255,255,255)"});
				$(this).children("ul").css({"z-index":"-2"}).stop().animate({"left":"0"},150,function(){
					$(this).hide();
				});
			})
		}).on("mouseout",function(){
			$(this).children("ol").css({"display":"none"});
		})
		$("#login_zh_name,#login_zh_pwd,#login_sj_name,#login_sj_pwd").focus(function(){
			$(this).css({"border-color":"#7abd54"});
			$(this).siblings("p").css({"display":"none"});
		})
		$("#login_zh_name,#login_zh_pwd,#login_sj_name,#login_sj_pwd").blur(function(){
			$(this).css({"border-color":"#e1e1e1"})
		})
		$(".denglu").click(function(){
			$("#login").css({"display":"block"});
			$(".login_zh").css({"display":"block"});
			$(".login_sj").css({"display":"none"});
		})
		$(".guanbi").click(function(){
			$("#login").css({"display":"none"});
		})
		var tz = own.getClass("login_box_hd")[0];
		var txt = own.getClass("login_box_txt")[0];
		var bg = own.getClass("login_box_bg")[0];
		var yhm = own.getCookie("sfdl");
		if(yhm !== ""){
			$(".dlyh").text(yhm);
			$(".denglu").text("");
			$(".tuichu").text("退出")
		}else{
			$(".dlyh").text("");
			$(".denglu").text("请登录");
			$(".tuichu").text("")
		}
		$(".tuichu").on("click",function(){
			console.log(1)
			own.removeCookie("sfdl");
			$(this).text("");
			$(".dlyh").text("");
			$(".denglu").text("请登录");
		})
		var flag = false;
		function hdyz(e){
			var e = e || window.event;
			var x = e.clientX - tz.offsetLeft;
			$(".yzm_bnwk").css({"display":"none"});
			document.onmousemove = function(e){
				var e = e || window.event;
				var mixW = 270 - tz.offsetWidth;
				var l = e.clientX - x;
				if(l < 0){
					l = 0;
				}
				if(l > mixW){
					l = mixW;
					txt.innerHTML = "验证通过";
					txt.style.color = "#fff";
					tz.style.background = "url(images/index/verify_2.png) no-repeat center #fff";
					tz.onmousedown = null;
					this.onmousemove = null;
					flag = true;
				}
				tz.style.left = l + "px";
				bg.style.width = l + "px";
				return false;
			}
			document.onmouseup = function(){
				var left = tz.offsetLeft;
				if(left < 226){
					left = 0;
				}else{
					left = left;
				}
				tz.style.left = left + "px";
				bg.style.width = left + "px";
				document.onmousemove = null;
				document.onmouseup = null;
			}
		}
		tz.onmousedown = function(){
			hdyz();
		}
		$(".login_top_zh").click(function(){
			$(".login_zh").css({"display":"block"});
			$(".login_sj").css({"display":"none"});
		})
		$(".login_top_sj").click(function(){
			$(".login_zh").css({"display":"none"});
			$(".login_sj").css({"display":"block"});
			tz.style.left = "0px";
			bg.style.width = "0px";
			tz.style.background = "url(images/index/verify_1.png) no-repeat center #fff";
			tz.onmousedown = function(){
				hdyz();
			}
		})
		$("#login_zh_btn").on("click",function(){
			var sjhv = $("#login_zh_name").val();
			var mmv = $("#login_zh_pwd").val();
			var cv = own.getCookie(sjhv);
			if(sjhv.length === 0){
				$(".zh_bnwk").css({"display":"block"});
				$("#login_zh_name").css({"border-color":"red"});
			}
			if(cv === mmv && mmv.length !== 0){
				location.href = "index.html";
				own.setCookie("sfdl",sjhv,15);
			}else{
				if(mmv.length === 0){
					$(".mm_bnwk").css({"display":"block"}).text("不能为空");
					$("#login_zh_pwd").css({"border-color":"red"});
				}else{
					$(".mm_bnwk").css({"display":"block"}).text("用户名和密码不正确");
					$("#login_zh_pwd").css({"border-color":"red"});
				}
			}
		})
		$("#login_sj_btn").on("click",function(){
			var sjhv = $("#login_sj_name").val();
			var mmv = $("#login_sj_pwd").val();
			var cv = own.getCookie(sjhv);
			if(sjhv.length === 0){
				$(".sjzh_bnwk").css({"display":"block"});
				$("#login_sj_name").css({"border-color":"red"});
			}
			if(cv === mmv && mmv.length !== 0 && flag){
				location.href = "index.html";
				own.setCookie("sfdl",sjhv,15);
			}else{
				if(mmv.length === 0){
					$(".sjmm_bnwk").css({"display":"block"}).text("不能为空");
					$("#login_sj_pwd").css({"border-color":"red"});
				}else{
					$(".sjmm_bnwk").css({"display":"block"}).text("用户名和密码不正确");
					$("#login_sj_pwd").css({"border-color":"red"});
				}
				if(!flag){
					$(".yzm_bnwk").css({"display":"block"});
				}
			}
		})
	}
});
